package com.hzit.order.controller;

import com.hzit.common.resp.Resp;
import com.hzit.order.resp.OrderInfo;
import com.hzit.order.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 订单接口
 */
@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private IOrderService iOrderService;

    @RequestMapping("/create")
    public  Resp<OrderInfo> createOrder(@RequestParam ("token") String token){

        Resp<OrderInfo> resp1 = new Resp<OrderInfo>();
        OrderInfo orderInfo = new OrderInfo();
        if(StringUtils.isEmpty(token)){
            resp1.setMsg("token不能为空");
            resp1.setCode("-1");
            resp1.setT(orderInfo);
            System.out.println("token不能为空");
            return resp1;
        }

        //查询商品信息
        //查询商品信息
        orderInfo = iOrderService.createOrder1();
        resp1.setCode("0");
        resp1.setMsg("请求成功");
        resp1.setT(orderInfo);
        return resp1;
    }

    @RequestMapping("/create1")
    public Resp<OrderInfo> createOrder1(@RequestParam ("token") String token){
        System.out.println("-------订单接口create1----------");
        Resp<OrderInfo> resp = new Resp<OrderInfo>();
        OrderInfo orderInfo = new OrderInfo();
        if(StringUtils.isEmpty(token)){

            resp.setCode("-1");
            resp.setMsg("token不能为空");
            resp.setT(orderInfo);
            System.out.println("token不能为空");
            return resp;
        }

        //查询商品信息
        orderInfo = iOrderService.createOrder1();
        resp.setCode("0");
        resp.setMsg("请求成功");
        resp.setT(orderInfo);
        return resp;
    }

}
